package com.my.ads.lib.live.service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

import com.my.ads.lib.live.account.SyncAdapter;

/**
 * Created by xuanyang on 2018/3/9.
 */

public class SyncService extends Service {


    // Storage for an instance of the sync adapter
    private static SyncAdapter sSyncAdapter = null;
    // Object to use as a thread-safe lock
    private static final Object sSyncAdapterLock = new Object();

    @Override
    public IBinder onBind(Intent intent) {
        return sSyncAdapter.getSyncAdapterBinder();
    }

    public SyncService() {
    }

    @Override
    public void onCreate() {
        super.onCreate();
        synchronized (sSyncAdapterLock) {
            sSyncAdapter = new SyncAdapter(getApplicationContext(), true);
        }
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        //TODO 保活之后执行的操作
        try{
            Intent tmp = new Intent(this, LiveService.class);
            startService(tmp);
        }catch (Exception e){
            e.printStackTrace();
        }

        return super.onStartCommand(intent, flags, startId);
    }


}
